<template>
  <div id="course" v-show="info">
    <c-title :hide="false" text="我的课程"></c-title>

    <div style="margin-top: -1px;">
      <van-cell-group>
          <van-cell @click.native="gotoVip" id="header" center>
            <div slot="title" class="user-info">
              <div  class="touxiang" >
                <img :src="memberInfo.avatar" style="width: 100%; height: 100%; border-radius: 1.5625rem;" />
              </div>
              <div class="nickname-wrapper">
                <p class="nickname">{{ memberInfo.nickname }}</p>
                <span class="level_name" > {{ memberInfo.level_name }}</span>
              </div>
            </div>
          </van-cell>
        </van-cell-group>
    </div>
    <ul class="course-list">
      <router-link :to="fun.getUrl('CourseMy')" tag="li">
        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/my_course.png" alt="" />
        <p>我的课程</p>
      </router-link>
      <router-link :to="fun.getUrl('CourseHistory')" tag="li">
        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/course_history.png" alt="" />
        <p>课程观看历史</p></router-link>
      <router-link :to="fun.getUrl('CourseReward')" tag="li">
        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/my_play_tour.png" alt="" />
        <p>我的打赏</p></router-link>
      <router-link :to="fun.getUrl('CourseIndex', { fromHome: 1 })" tag="li">
        <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/all_course.png" alt="" />
        <p>全部课程</p></router-link>
    </ul>
    <div class="main-box">
      <div class="carefully_chosen_more">
        <div class="title_name">推荐课程</div>
        <router-link :to="fun.getUrl('CourseIndex', { fromHome: 1 })" tag="div">
          <div class="right">
            <span>更多</span>
            <i class="fa fa-angle-right"></i></div>
        </router-link>
      </div>
      <div class="full_video">
        <d-list class="DList" :StyleOptions="{'font-size':'0.75rem'}" :loading="more_loading" :finished="finished" @load="onLoad" >
          <ul class="full_video_list">
              <li  v-for="(item,i) in newGoodList" :key='i' @click="goToDetail(item.goods_id)">
                <div class="full_video_left">
                  <img :src="item.thumb"  alt="">
                </div>
                <div class="full_video_right">
                  <div>
                    <div class="video_name">{{ item.goods_title }}</div>
                    <div class="teacher-info" >
                      <div style="display: flex;align-items: center;"  v-if="item.member_avatar">
                        <img  style="margin-right: 0.25rem;width: 1.375rem;height: 1.375rem;border-radius: 100px;"  :src="item.member_avatar" alt="">
                        <span >{{ item.real_name }}</span>
                      </div>
                      <div>共{{ item.course_chapter_num }}节课</div>
                    </div>
                  </div>
                  <div class="full_video_bottom">
                    <div class="price" v-if="item.has_one_goods && item.has_one_goods.vip_level_status && item.has_one_goods.vip_level_status.status==1">
                      {{$i18n.t('money')}} <span class="cost2">{{ item.has_one_goods.vip_level_status.word }}</span>
                    </div>
                    <div class="price" v-else>
                      <span  style="font-size: 0.75rem;margin-right: 0.1563rem;">{{$i18n.t('money')}}</span>
                      <span style="font-size: 1.125rem;">{{item.price }}</span>
                    </div>
                    <div class="buy">
                      <span>已购</span>
                      <span style="margin-left: 0.1563rem;">{{item.total_sales}}</span>
                    </div>
                  </div>
                </div>
              </li>
          </ul>
        </d-list>
        <div class="video_more" @click="getMoreData" v-if="isLoadMore">
            <span>{{ $i18n.t("加载更多") }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import course_manage_controller from "./course_manage_controller";
export default course_manage_controller;
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" rel="stylesheet/scss" scoped>

::v-deep .van-nav-bar__content {
    background: #FE5E56;
  }

  ::v-deep .van-button__content {
    background: #FE5E56;
  }

  ::v-deep .van-nav-bar__title {
    color: #fff;
    font-size: 1.125rem;
    font-weight: unset;
  }

  ::v-deep .van-nav-bar .van-icon {
    color: #fff;
  }
  .main-box{
    margin: 0.625rem 0.75rem;
    padding: 0.75rem .75rem 0;
    border-radius: 0.625rem;
    background: #fff;
  }
#course {
  min-height: 100vh;

  .nickname {
    font-size: 1rem;
    font-weight: bold;
  }

  .user-info {
    display: flex;
    color: #fff;
    text-align: left;
  }

  .level_name {
    display: inline-block;
    margin-top: 0.5375rem;
    height: 1.25rem;
    line-height: 1.25rem;
    color: #FE5E56;
    font-size: 0.6875rem;
    padding: 0 0.5rem;
    background-color: #fff;
    border-radius: 100px;
    box-sizing: border-box;
  }

  .nickname-wrapper {
    padding-top: 0.3875rem;
    // padding-bottom: 0.1875rem;
  }

  .course-list {
    margin: 0.625rem 0.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.625rem;
    background: #fff;
    display: flex;
    justify-content: space-between;
    color: #000;
    font-size: 0.75rem;
  }

}

#header {
  padding: 1.25rem;
  background-color: #FE5E56;
  line-height: 1rem;

  span {
    color: #fff;
  }
}

.touxiang {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  margin-right: 0.625rem;
  // border: solid 0.125rem #fff;
  overflow: hidden;
  flex-shrink: 0;
}

#last {
  border: none;
}

.box {
  background-color: #fff;
  width: 100%;

  .list {
    font-size: 15px;
    height: 2.75rem;
    line-height: 2.75rem;
    border-bottom: solid 0.0625rem #ebebeb;
    margin-left: 0.875rem;
    padding-right: 0.875rem;
    text-align: left;
    display: flex;
    align-items: center;

    i.fa.fa-angle-right {
      line-height: 2.75rem;
      font-size: 1.5rem;
      color: #c9c9c9;
      float: right;
      position: absolute;
      right: 0.875rem;
    }

    span:last-child {
      position: absolute;
      right: 1.625rem;
    }
  }
}

#header .van-cell__title {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

::v-deep .van-cell--clickable:active {
  background-color: #fff;
}

.carefully_chosen_more {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .title_name{
    font-size: 1rem;
    font-weight: bold;
  }

  .bg-img {
    position: absolute;
    width: 1rem;
    height: 100%;
    left: 0.5625rem;
  }

  .left {
    line-height: 1.156rem;
    height: 1.156rem;
    font-size: 1rem;
  }

  .right {
    line-height: 1.156rem;
    height: 1.156rem;
    color: #999;
    font-size: 0.875rem;
    display: flex;
    align-items: center;

    i {
      padding-left:0.3125rem;
      font-size: 0.875rem;
    }
  }
}
.full_video {


  .left {
    text-align: left;
  }

  .full_video_list {
    li:last-child{
      margin-bottom: 0;
    }

    li {
      margin: 0.75rem 0;
      display: flex;

      .full_video_left {
        overflow: hidden;
        width: 6.25rem;
        height: 6.25rem;
        margin-right: 0.75rem;
        flex-shrink: 0;

        img {
          width: 100%;
          height: 100%;
          border-radius: 0.3125rem;
        }
      }

      .full_video_right {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        // padding-top: 0.2rem;
        .teacher-info{
          margin-top: 0.5rem;
          position: relative;
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 0.75rem;
          color: #4B6AA7;
          padding: 0 0.75rem;
          height: 1.625rem;
          line-height: 1.625rem;
        }
        .teacher-info::after{
          position: absolute;
          content:"";
          left: 0;right: 0;top: 0;
          bottom: 0;
          background: #4B6AA7;
          opacity: .05;
        }

        .video_name {
          text-align: left;
          line-height: 1rem;
          // height: 1.5rem;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          // margin-bottom: 0.25rem;
        }

        .full_video_bottom {
          display: flex;
          align-items: center;
          .total-sales{
            margin-left: 0.1875rem;
          }
          .buy{
            color: #999999;
            display: flex;
            font-size: 0.75rem;
            align-items: flex-end;
            margin-left: 0.5rem;
          }
          .leftContent {
            .pitch_number {
              text-align: left;
              height: 0.9rem;
              line-height: 0.9rem;
              font-size: 0.875rem;
              color: #999;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
              width: 8rem;
            }

            .left {
              width: 8rem;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
              font-size: 0.75rem;
              color: #999;
              text-align: left;
            }
          }

          .price {
            line-height: 0.938rem;
            height: 0.938rem;
            font-size: 1.125rem;
            color: #F15353;
            margin-right: 0.563rem;
            text-align: right;

            .cost2 {
              color: #ccc;
              font-size: 0.75rem;
              padding-left: 0.4rem;
            }
          }

          .gratis {
            width: 6rem;
            white-space: nowrap;
            overflow: hidden;
            line-height: 0.938rem;
            height: 0.938rem;
            text-overflow: ellipsis;
            color: #ff9d27;
            font-size: 0.875rem;
            text-align: right;
            margin-right: 0.563rem;
          }
        }
      }
    }
  }

  .video_more {
    font-size: 0.799rem;
    line-height: 0.938rem;
    height: 0.938rem;
    color: #999;
    padding-bottom: 1.531rem;
  }
}
</style>
